﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsSelectionReactor : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsSelectionReactor(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsSelectionReactor obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsSelectionReactor()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsSelectionReactor(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public virtual bool selected(OdGiDrawableDesc pDrawableDesc)
		{
			bool result = GlobalsPINVOKE.OdGsSelectionReactor_selected__SWIG_0(this.swigCPtr, OdGiDrawableDesc.getCPtr(pDrawableDesc));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual uint selected(OdGiPathNode arg0, OdGiViewport arg1)
		{
			uint result = this.SwigDerivedClassHasMethod("selected", OdGsSelectionReactor.swigMethodTypes1) ? GlobalsPINVOKE.OdGsSelectionReactor_selectedSwigExplicitOdGsSelectionReactor__SWIG_1(this.swigCPtr, OdGiPathNode.getCPtr(arg0), OdGiViewport.getCPtr(arg1)) : GlobalsPINVOKE.OdGsSelectionReactor_selected__SWIG_1(this.swigCPtr, OdGiPathNode.getCPtr(arg0), OdGiViewport.getCPtr(arg1));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsSelectionReactor() : this(GlobalsPINVOKE.new_OdGsSelectionReactor(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("selected", OdGsSelectionReactor.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdGsSelectionReactor.SwigDelegateOdGsSelectionReactor_0(this.SwigDirectorselected__SWIG_0);
			}
			if (this.SwigDerivedClassHasMethod("selected", OdGsSelectionReactor.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdGsSelectionReactor.SwigDelegateOdGsSelectionReactor_1(this.SwigDirectorselected__SWIG_1);
			}
			GlobalsPINVOKE.OdGsSelectionReactor_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdGsSelectionReactor));
		}

		private bool SwigDirectorselected__SWIG_0(IntPtr pDrawableDesc)
		{
			return this.selected(new OdGiDrawableDesc(pDrawableDesc, false));
		}

		private uint SwigDirectorselected__SWIG_1(IntPtr arg0, IntPtr arg1)
		{
			return this.selected(new OdGiPathNode(arg0, false), (OdGiViewport)Teigha.Core.Helpers.odrxCreateObjectInternal(arg1, false));
		}

		public const uint kNotImplemented = 2147483648u;

		public const int kContinue = 0;

		public const int kBreak = 1;

		public const int kSkipDrawable = 2;

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		private OdGsSelectionReactor.SwigDelegateOdGsSelectionReactor_0 swigDelegate0;

		private OdGsSelectionReactor.SwigDelegateOdGsSelectionReactor_1 swigDelegate1;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdGiDrawableDesc)
		};

		private static Type[] swigMethodTypes1 = new Type[]
		{
			typeof(OdGiPathNode),
			typeof(OdGiViewport)
		};

		public delegate bool SwigDelegateOdGsSelectionReactor_0(IntPtr pDrawableDesc);

		public delegate uint SwigDelegateOdGsSelectionReactor_1(IntPtr arg0, IntPtr arg1);
	}
}
